<template>
登录页
</template>

<script >
import { goSsoAuthUrl } from '@/api/permission';
import { useRoute } from 'vue-router'
import {loginByTicket} from "@/api/permission";
import storage from "store";
import {ACCESS_TOKEN} from "@/store/mutation-types";
export default {
  name: "login",
  setup(){
    const route = useRoute();
    let { back, ticket } = route.query
    if(ticket){
      loginByTicket(ticket).then(res => {
        const { token } = res
        storage.set(ACCESS_TOKEN, token)
        // 重定向
        location.href = back;
      })
    }else{
      goSsoAuthUrl(location.href)
        .then(res => {
          location.href = res.url
        })
    }
  },
}
</script>
